import {reqUserAddressList,reqTradeInfo} from '@/api'
import {Message} from 'element-ui'


const actions = {
	async getUserAddressList({commit}){
		const result = await reqUserAddressList()
		if(result.code === 200){
			commit('SAVE_USER_ADDRESS_LIST',result.data)
		}else{
			Message.error(result.message+'!')
		}
	},
	async getTradeInfo({commit}){
		const result = await reqTradeInfo()
		if(result.code === 200){
			commit('SAVE_TRADE_INFO',result.data)
		}else{
			Message.error(result.message+'!')
		}
	}
}

const mutations = {
	SAVE_USER_ADDRESS_LIST(state,list){
		state.userAddressList = list
	},
	SAVE_TRADE_INFO(state,info){
		state.tradeInfo = info
	}
}

const state = {
	userAddressList:[],
	tradeInfo:{}
}

const getters = {}

export default {
	namespaced:true,
	actions,
	mutations,
	state,
	getters
}